import 'package:device_uuid/device_uuid.dart';
import 'package:flutter/material.dart';
import 'package:my_demo_flutter/pages/animation_test_page.dart';
import 'package:my_demo_flutter/pages/dio_test_page.dart';
import 'package:my_demo_flutter/pages/fijk_player_test_page.dart';
import 'package:my_demo_flutter/pages/main_page.dart';
import 'package:my_demo_flutter/pages/pageview_test_page.dart';
import 'package:my_demo_flutter/pages/photo_view_test_page.dart';
import 'package:my_demo_flutter/pages/test0216.dart';
import 'package:package_info_plus/package_info_plus.dart';

import 'my_base_lib/base_lib.dart';

const String passwordAllowChars =
    "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

class AppConfigs {
  static const bool isDebug = !bool.fromEnvironment('dart.vm.product');
  static String? appName;
  static String? packageName;
  static String? deviceId;
  static String? version;
  static String? buildNumber;

  static init() async {
    if (CommonUtils.isNotEmpty(deviceId)) {
      return;
    }

    await FileUtils.init();
    await SpUtils.init();
    deviceId = await _getDeviceId();
    PackageInfo packageInfo = await PackageInfo.fromPlatform();

    appName = packageInfo.appName;
    packageName = packageInfo.packageName;
    version = packageInfo.version;
    buildNumber = packageInfo.buildNumber;
    LogUtils.d(
        "isDebug = $isDebug , deviceId = $deviceId , version = $version buildNumber = $buildNumber",
        tag: '初始化信息');
  }

  static Future<String> _getDeviceId() async {
    return await DeviceUuid().getUUID() ?? "";
  }

  //路由配置
  static Map<String, Widget Function(BuildContext)> routes = {
    MainPage.routeName: (context) => MainPage(),
    PageViewTestPage.routeName: (context) => PageViewTestPage(),
    PhotoViewTestPage.routeName: (context, {arguments}) =>
        PhotoViewTestPage(arguments: arguments),
    DioTestPage.routeName: (context) => DioTestPage(),
    FijkPlayerTestPage.routeName: (context) => FijkPlayerTestPage(),
    AnimationTestPage.routeName: (context) => AnimationTestPage(),
    RefreshAndLoadMorePage.routeName: (context) => RefreshAndLoadMorePage(),

    /* ResetPasswordPage2.routeName: (context, {arguments}) =>
        ResetPasswordPage2(email: arguments),*/
    /*WelcomeCreateAvatarPage.routeName: (context) =>
        const WelcomeCreateAvatarPage(),*/
  };
}
